home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades ƒ / Slide fade.c < prev    next >
Text File  |  1994-04-19  |  2KB  |  87 lines

  1. /**********************************************************************\
  2.  
  3. File:        Slide fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 1
  28. #define theWindowWidth (boundsRect.right-boundsRect.left)
  29. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  30.  
  31. pascal short SlideFade(Rect boundsRect, Pattern *thePattern);
  32.  
  33. /* Split the screen into 10 sections, then scroll each section left or right
  34.    (alternating), starting with the top section and working towards the bottom. */
  35.    
  36. pascal short SlideFade(Rect boundsRect, Pattern *thePattern)
  37. {
  38.     int                x, y;
  39.     Rect            dest;
  40.     Rect            scrollsource;
  41.     int                direction;
  42.     int                BoxSize, StripSize;
  43.     
  44.     BoxSize=theWindowWidth/25;
  45.     StripSize=theWindowHeight/10;
  46.     
  47.     direction = 0;
  48.     for(y = 0; y < theWindowHeight; y += StripSize)
  49.     {
  50.         scrollsource = boundsRect;
  51.         scrollsource.top+=y;
  52.         scrollsource.bottom = scrollsource.top + StripSize;
  53.         
  54.         dest = scrollsource;
  55.         if(direction == 0)
  56.         {
  57.             dest.right=dest.left+BoxSize;
  58.         
  59.             for(x = boundsRect.right - BoxSize; x >= boundsRect.left; x -= BoxSize)
  60.             {
  61.                 StartTiming();
  62.                 ScrollTheRect(&scrollsource, BoxSize, 0, 0L);
  63.                 FillRect(&dest, *thePattern);
  64.                 TimeCorrection(CorrectTime);
  65.             }
  66.             FillRect(&scrollsource, *thePattern);
  67.         }
  68.         else
  69.         {
  70.             dest.left = dest.right - BoxSize;
  71.             
  72.             for(x = boundsRect.left+BoxSize; x <= boundsRect.right; x += BoxSize)
  73.             {
  74.                 StartTiming();
  75.                 ScrollTheRect(&scrollsource, -BoxSize, 0, 0L);
  76.                 FillRect(&dest, *thePattern);
  77.                 TimeCorrection(CorrectTime);
  78.             }
  79.             FillRect(&scrollsource, *thePattern);
  80.         }
  81.         
  82.         direction = 1 - direction;
  83.     }
  84.     
  85.     return 0;
  86. }
  87.